package com.example.controller;

import java.util.Arrays;

import com.example.vo.per.EmpTurnover;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.vo.ResultVo;
import com.github.pagehelper.PageInfo;
import com.example.pojo.PositionTransfer;
import com.example.service.IPositionTransferService;
import io.swagger.annotations.Api;
/**
 * <p>
 * 岗位调动申请表 前端控制器
 * </p>
 *
 * @author wsl
 * @since 2022-05-07
 */
@RestController
@RequestMapping("/positionTransfer")
@Api(tags = "岗位调动申请表",value = "")
@CrossOrigin(allowCredentials = "true")
public class PositionTransferController {

    @Autowired
    private IPositionTransferService pts;

    @ApiOperation(value = "查询岗位调动申请表")
    @GetMapping("")
    public ResultVo getPositionTransferPageInfo(
        @RequestParam(defaultValue = "1") Integer pageNum,
        @RequestParam(defaultValue = "10") Integer pageSize) {
        PageInfo<EmpTurnover> info = pts.selResByEmpIdList(pageNum, pageSize);
        if (info != null){
            return ResultVo.response(info);
        }
        return ResultVo.error();
    }

    @ApiOperation(value = "新增岗位调动申请表")
    @PostMapping("/add")
    public ResultVo addPositionTransfer(@RequestBody PositionTransfer positionTransfer) {
        return pts.addPos(positionTransfer);
    }

    @ApiOperation(value = "修改岗位调动申请表")
    @PutMapping("")
    public ResultVo updatePositionTransfer(@RequestParam("rids") Integer[] rids) {
        System.err.println("---> " + rids);
        if (rids != null){
            pts.uptPos(rids);
        }
        return ResultVo.ok();
    }

    @ApiOperation(value = "删除岗位调动申请表")
    @DeleteMapping("")
    public ResultVo deletePositionTransfer(@RequestParam("rids") Integer[] rids) {
        System.err.println("---> " + rids);
        if (rids != null){
            pts.delPos(rids);
        }
        return ResultVo.ok();
    }
}
